﻿function DashboardPresenter(eventHub) {
    var self = this;
    /*=========================================================================================================*/
    this.RegisterEventListeners = function() {
        eventHub.AddEventListener(PasEvents.OnLocationChanged, function(eventTypes, eventArgs) { self.LocationChanged(eventArgs); });
    };

    this.LocationChanged = function(eventArgs) {
        // Our locationChanged, so
        var l = eventArgs.Location;

        var url = "http://localhost:2000/Home/Dashboard/" + eventArgs.wardCode + "/?location=" + encodeURIComponent(l);
        var ajaxOptions = {
            url: url,
            async: false,
            cache: false,
            type: "POST",
            success: this.LocationChangedSuccess,
            error: this.LocationChangedError
        };
        $.ajax(ajaxOptions);
    };

        this.LocationChangedSuccess = function(data) {
            $("#dashboard").html(data);

        };

        this.LocationChangedError = function(xhr, description, error) {
            alert("LocationChangedError");
 
        };

    
};